#pragma once
#ifndef _KLAS_GL_RENDERING_CORE_HPP_
#define _KLAS_GL_RENDERING_CORE_HPP_

#include "../../Library.hpp"
#include "../../Platform.hpp"
#include "../../graphics/RenderingCore.hpp"

#include "../../GLLibs.hpp"
#include "../PrimitiveTypes.hpp"

#include <vector>
using std::vector;

namespace klas
{
  namespace graphics
  {
    namespace gl
    {
      class KLAS_API GLRenderingCore: public RenderingCore, public library::Gl
      {
      public:
        
        GLRenderingCore(uint32 sizeHint = 1000);
        virtual ~GLRenderingCore();

        virtual void add(string text, Font* font, const Color& col, const Transformation& transform, double transparency, uint16 layer = 0);
        virtual void add(Texture* tex, const Transformation& transform, double transparency, const Color& col = colors::White, uint16 layer = 1);
        virtual void add(primitiveTypes::sPrimitiveType type, const Transformation& transform, const Color& col, double transparency, uint16 layer = 1);

        virtual void render(const math::Rectd& cam, uint16 layer = 0);
        virtual void clearCache(bool removeText = true);

      private:
        vector<RenderingCore::internalTexture>    m_textures;
        vector<RenderingCore::internalText>       m_text;
        vector<RenderingCore::internalPrimitive>  m_primitives;

        void applyTransform(const Transformation& transform, const math::Rectd& cam);

        GLuint* m_buffers;
        static const uint32 IDX_TEXTURE;
        static const uint32 IDX_CIRCLE;
        static const uint32 IDX_TRIANGLE;
        static const uint32 IDX_LINE;
        // It should be noted that rectangles use the texture vbo, but just don't call the texture coords.
      };
    }
  }
}

#endif